﻿using Abp.Application.Services;
using Abp.Application.Services.Dto;
using Abp.Authorization;
using Abp.Domain.Repositories;
using Microsoft.EntityFrameworkCore;
using MVlog.Authorization;
using MVlog.Core;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace MVlog.Application
{
    [AbpAuthorize(AppPermissions.Pages_Tag)]
    public class TagAppService : AsyncCrudAppService<Tag, TagDto, long, GetTagInput, CreateTagInput, UpdateTagInput>, ITagAppService
    {

        public TagAppService(IRepository<Tag, long> repository)
           : base(repository)
        {
        }

        /// <summary>
        /// 获取所有标签
        /// </summary>
        /// <returns></returns>
        public async Task<ListResultDto<TagDto>> GetTags()
        {
            var tags = await Repository.GetAll().ToListAsync();
            var returnDto = ObjectMapper.Map<List<TagDto>>(tags);
            return new ListResultDto<TagDto>(returnDto);
        }
    }
}
